package com.xr.hr.workReport;

import com.xr.common.CommUtil;
import com.xr.common.Tools;
import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * makeQuarterlyReportViewModel
 */
public class makeQuarterlyReportViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
    // Add your code here
    super.doUpdateData(parameters, outParameters);
  }
  public void quarterSave(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
  Dataset dsWh=getDataset("datasetQuarterHead");
  Dataset dsW=getDataset("datasetQuarter");
  DBStatement dbs=new DBStatement();
  
  dsW.moveFirst();
  while(!dsW.isLast()){
	 
	  dsW.setValue("ONOFF_STATION_ID", CommUtil.getOnoffStationId());
	  dsW.setValue("CREATE_ID", CommUtil.getEmployeeId());
	  dsW.setValue("NIAN", dsWh.getValue("NIAN"));
	  dsW.setValue("QUARTER", dsWh.getValue("QUARTER"));
	  dsW.setValue("START_DATE", dsWh.getValue("START_DATE"));
	  dsW.setValue("END_DATE", dsWh.getValue("END_DATE"));
	  
	  if(dsW.getRecordState()==Record.STATE_MODIFIED){
		  dsW.setValue("MODIFY_DATE", Tools.format(new java.util.Date(),"yyyy-MM-dd HH:mm:ss") );
		  dsW.setValue("MODIFY_ID", CommUtil.getEmployeeId());
	  }
	  
	  dsW.moveNext();
  } 
  CommUtil.dbsUpdateData(dbs, dsW, "EMP_WORK_MONTH", "EMP_WORK_Quarter_ID", "general");
  RecordIterator ri = dsW.recordIterator();
  ri.setVisibility(Dataset.FILTER_DELETED);
  while (ri.hasNext()) {
    Record record = ri.nextRecord();
    CommUtil.executeUpdate(dbs, "update EMP_WORK_MONTH set dr=1 where EMP_WORK_Quarter_ID="+record.getString("EMP_WORK_Quarter_ID"));
  }
  dbs.close();
  
//super.doUpdateData(parameters, outParameters);
}
  
}
